package com.config;

import io.grpc.netty.GrpcSslContexts;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.net.ssl.SSLException;
import java.io.File;

/**
 * @author 何永豪
 * @className GrpcProperties
 * @description TODO
 * @date 2023/11/7 16:40
 */
@Component
@ConfigurationProperties(prefix = "grpc")
@Data
public class GrpcProperties {

    private Integer port;

    private String  serverIp;

    private String serverCertPath;

    private String serverPrivateKeyPath;

    private String serverTrustCertPath;

    private String clientCertPath;

    private String clientCertChainPath;

    private String clientPrivateKeyPath;

    /*public SslContext buildClentSslContext() throws SSLException {
        SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
        sslContextBuilder.trustManager(new File(clientCertPath));
        sslContextBuilder.keyManager(new File(clientCertChainPath),new File(clientPrivateKeyPath));
        return sslContextBuilder.build();
    }*/

}
